<template>
	<view class="p30">
		<view class="p20 radius20 bg-fff">
			<view class="flex">
				<u-avatar :src="data.avatar||''" size="110" :showSex="!!data.sex"
					@click="$tool.lookImg([data.avatar||''])"
					:sex-icon="data.sex == 2 ? 'man' : data.sex == 1 ? 'woman' : 'account'" />
				<view class="fs28 fw-700 u-line-1 ml20">{{data.name}}</view>
				<view class="ml10" v-if="data.is_name_auth==1">
					<image src="/static/img/index/ysm.png" class="w116 h36 db " mode=""></image>
				</view>
				<view class="flex1"></view>
				<button class="u-reset-button color-666 fs24" open-type="share" style="background: #0000;"
					@click="share()" v-if="data.is_homepage">分享主页</button>
				<!-- <view class="color-666 fs24" >分享主页</view> -->
			</view>
			<view class="flex flex-wrap fs26">
				<view class="w320 pt20">
					<text class="color-666">状态：</text>
					<text class="color-zs">{{data.status_text}}</text>
				</view>
				<view class="w320 pt20">
					<text class="color-666">年龄：</text>
					<text>{{data.age}}岁</text>
				</view>
				<view class="w320 pt20">
					<text class="color-666">工龄：</text>
					<text>{{data.work_year}}年</text>
				</view>
				<view class="w320 pt20">
					<text class="color-666">城市：</text>
					<text>{{data.city_name}}</text>
				</view>
				<view class="w320 pt20">
					<text class="color-666">陪诊：</text>
					<text>{{data.service_num}}次</text>
				</view>
				<view class="w320 pt20">
					<text class="color-666">好评：</text>
					<text>{{data.good_comment}}次</text>
				</view>
			</view>
		</view>
		<view class="radius20 ov-h mt20 bg-fff">
			<u-tabs :list="tabList" :activeColor="$zs" :current="current" @change="changeTab" />

			<view class="" v-for="(item, index) in tabList" :key="index">
				<block v-if="current===index">
					<hospitalList v-if="item.type == 'yy'" :list="item.list" />
					<!-- <masterList  :list="item.list" /> -->
					<view class="bg-fff radius12 mt20" v-else-if="item.type == 'pl'">
						<view class="p20  bg-fff radius20 flex flex-wrap ">
							<view v-for="(item2,index2) in wordTabs" :key="index2"
								@click="item.apiParams.type=item2.type,getList()"
								class="flex row-center h60 w120 bg-f8f radius32 mr30 mb24 color-999 border"
								:class="item.apiParams.type==item2.type?'border-zs color-zs':''">
								{{item2.name}}
							</view>
						</view>
						<u-empty v-if="!item.list.length" />
						<view v-for="(item2,index2) in item.list" :key="index2" class="p20 border-b">
							<comment :item="item2" />
						</view>
					</view>
					<view class="p30" v-else-if="item.type == 'user'">
						<view class="fs30 color-666 fw-w">资格证书</view>
						<view class="pt20">
							<z-imgs :paths="data.credentials" look />
						</view>
						<view class="fs30 mt20 color-666 fw-w">体检报告</view>
						<view class="pt20">
							<z-imgs :paths="data.report" look />
						</view>
					</view>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: "",
				current: 0,
				tabList: [{
						name: '服务医院',
						api: '/member/search/masterHospital',
						type: 'yy',
						id: 1,
						list: []
					},
					{
						name: '用户评价',
						api: '/member/search/masterComment',
						type: 'pl',
						list: [],
						apiParams: {
							type: 'all'
						}
					},
					{
						name: '人员资料',
						type: 'user',
					},
				],
				page: 1,
				wordTabs: [{
						type: 'all',
						name: '全部'
					},
					{
						type: 'good',
						name: '好评'
					},
					{
						type: 'medium',
						name: '中评'
					},
					{
						type: 'bad',
						name: '差评'
					},
				]
			};
		},
		onShow() {
			this.getData()
			this.getList()
		},
		onReachBottom() {
			this.getList('down')
		},
		methods: {
			share() {
				// #ifdef MP-WEIXIN

				// #endif
				// #ifndef MP-WEIXIN
				let copy = this.$global.href + '#/?masterid=' + this.data.id
				this.$tool.copy(copy, '复制分享链接成功')
				// #endif
			},
			getData() {
				this.$request('/member/search/masterInfo', this.$params).then(res => {
					let data = res.data
					this.data = data
					// #ifdef MP-WEIXIN
					if (data.is_homepage) {
						this.shareData.title = "陪诊师" + (data.name || "") + "的专属主页"
						this.shareData.path = '/pages/index/index?masterid=' + this.data.id
						// console.log(this.shareData);
					}
					// #endif
				})
			},
			changeTab(e) {
				this.current = e
				this.getList()
			},
			getList(e) {
				let data = this.tabList?.[this.current] || ''
				if (!data.api) return
				if (!data) return
				e == 'down' ? this.page++ : this.page = 1
				let params = {
					...this.$params,
					...data.apiParams,
					page: this.page,
				}
				this.$request(data.api, params).then(res => {
					let list = res.data.data
					e == 'down' ? data.list.push(...list) : data.list = list
				})
			},
		}
	}
</script>

<style lang="scss">

</style>